 AREA |.text|, CODE, READONLY, ALIGN=2
    THUMB
    REQUIRE8
    PRESERVE8


my_setjmp PROC
	EXPORT	my_setjmp
	STR		r0,[r0]
	STR		r1,[r0,#4]
	STR		r2,[r0,#8]
	STR		r3,[r0,#12]
	STR		r4,[r0,#16]
	STR		r5,[r0,#20]
	STR		r6,[r0,#24]
	STR		r7,[r0,#28]
	mov     r1,lr
	STR		r1,[r0,#32]
	mov     r1,sp
	STR		r1,[r0,#36]
	LDR		r1,=return_from_longjmp
	STR		r1,[r0,#40]
	MOVS    r0,#0
	BX		r14
	
return_from_longjmp
	STR		r1,[r0]
	LDR		r1,[r0,#36]
	mov		sp, r1
	LDR		r1,[r0,#32]
	mov     lr, r1
	LDR		r1,[r0,#4]
	LDR		r2,[r0,#8]
	LDR		r3,[r0,#12]
	LDR		r4,[r0,#16]
	LDR		r5,[r0,#20]
	LDR		r6,[r0,#24]
	LDR		r7,[r0,#28]	
	LDR		r0,[r0]
	BX		r14
	
	ENDP



my_longjmp	PROC
	EXPORT	my_longjmp
	LDR		r2,[r0,#40]
	BX		r2
	ENDP
		
		 ALIGN   4

    END
